package com.human.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.human.entity.Emprp;
import com.human.dao.EmprpMapper;
import com.human.entity.ResultVo;
import com.human.service.IEmprpService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 员工奖惩情况 服务实现类
 * </p>
 *
 * @author jzq
 * @since 2023-02-28
 */
@Service
public class EmprpServiceImpl extends ServiceImpl<EmprpMapper, Emprp> implements IEmprpService {

    @Resource
    EmprpMapper emprpMapper;

    @Override
    public ResultVo<Page> page(int current, int pageSize, String name) {
        //分页构造器
        Page pageInfo = new Page(current, pageSize);

        //执行查询
        IPage emprpAndEmp = emprpMapper.getEmprpAndEmp(pageInfo, name);
        return new ResultVo<Page>(true, "查询成功", emprpAndEmp);
    }

    @Override
    public ResultVo addEmprp(Emprp emprp) {
        int i = emprpMapper.addEmprp(emprp);
        if (i > 0) {
            return new ResultVo<>(true, "添加成功");
        }
        return new ResultVo<>(false, "添加失败");
    }

    @Override
    public ResultVo updateEmprp(Emprp emprp) {
        int i = emprpMapper.updateEmprp(emprp);
        if (i > 0) {
            return new ResultVo<>(true, "修改成功");
        }
        return new ResultVo<>(false, "修改失败");
    }

    @Override
    public ResultVo getEmprpById(Integer id) {
        Emprp emprp = emprpMapper.selectById(id);
        return new ResultVo(true, "查询成功", emprp);
    }
}
